"Holds key string to use for god-mode support.")
(defadvice god-mode-lookup-command
- (before which-key--god-mode-lookup-command-advice disable)
- (setq which-key--god-mode-key-string (ad-get-arg 0)))
-
-(defadvice god-mode-self-insert
- (after which-key--god-mode-self-insert-advice disable)
- (which-key--hide-popup))
+ (around which-key--god-mode-lookup-command-advice disable)
+ (setq which-key--god-mode-key-string (ad-get-arg 0))
+ (unwind-protect
+ ad-do-it
+ (when (bound-and-true-p which-key-mode)
+ (which-key--hide-popup))))
(defun which-key-enable-god-mode-support (&optional disable)
"Enable support for god-mode if non-nil. This is experimental,
(interactive "P")
(setq which-key--god-mode-support-enabled (null disable))
(if disable
- (progn
- (ad-disable-advice
- 'god-mode-lookup-command
- 'before 'which-key--god-mode-lookup-command-advice)
- (ad-disable-advice
- 'god-mode-self-insert
- 'after 'which-key--god-mode-self-insert-advice))
+ (ad-disable-advice
+ 'god-mode-lookup-command
+ 'around 'which-key--god-mode-lookup-command-advice)
(ad-enable-advice
'god-mode-lookup-command
- 'before 'which-key--god-mode-lookup-command-advice)
- (ad-enable-advice
- 'god-mode-self-insert
- 'after 'which-key--god-mode-self-insert-advice))
- (ad-activate 'god-mode-lookup-command)
- (ad-activate 'god-mode-self-insert))
+ 'around 'which-key--god-mode-lookup-command-advice))
+ (ad-activate 'god-mode-lookup-command))
;;;###autoload
(define-minor-mode which-key-mode